// pages/meetingsummary/meetingsummary.js
import request from "../../utils/request"
Page({
  onUpdateData(e) {
    // 在这里更新父组件的数据
    console.log(e)
    this.setData({ language: e.detail.newData });
    wx.setStorage({
      key: 'language',
      data: this.data.language,
      success: function (res) {
      }
    });
  },
  onLanguageTap() {
    const that = this;
    wx.showActionSheet({
        itemList: ['English', '中文','繁体'],
        success(res) {
            if (res.tapIndex === 0) {
                that.setData({ language: 'en' });
            } else if (res.tapIndex === 1) {
                that.setData({ language: 'zh' });
            }else{
              that.setData({language:'tr'})
            }
            wx.setStorage({
              key: 'language',
              data: that.data.language,
              success: function (res) {
              }
            });
        }
    });
  },

  /**
   * 页面的初始数据
   */
  data: {
    index :'',
    bagImg:'',
    color:'',
    logImg:'',
    event_name:'',
    event_desc:'',
    event_time:'',
    event_address:'',
    mettingdata:'',
    CouncilMeeting:'',
    imagedetail:'',
    abstractdetail1data:{
      id:'',
      type:''
    }

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onItemClick:function(e){
    const index = e.currentTarget.dataset.index;
    console.log(this.data.mettingdata[index],"678")
    if(this.data.mettingdata[index].type === ""){
     this.setData({
       imagedetail:this.data.mettingdata[index].src
     })
     wx.navigateTo({
      url: '/pages/imagedetail/imagedetail?param1='+JSON.stringify(this.data.imagedetail)
    })
    }else if(this.data.mettingdata[index].type === "meeting"){
      this.setData({
        'abstractdetail1data.type':this.data.mettingdata[index].type
      })
      wx.navigateTo({
        url: '/pages/abstractdetail1/abstractdatail1?param1='+JSON.stringify(this.data.abstractdetail1data)
      })
    }else if(this.data.mettingdata[index].type === "dinner"){
      this.setData({
        'abstractdetail1data.type':this.data.mettingdata[index].type
      })
      wx.navigateTo({
        url: '/pages/abstractdetail1/abstractdatail1?param1='+JSON.stringify(this.data.abstractdetail1data)
      })
    }

  },
  async onLoad(options) {
    const index = JSON.parse(options.param1)
    this.setData({
      index:index
    })
    
    const res2 = await request({
      url: "/stractdetail",
      data: {
        id: index,
      }
    })
    console.log(res2.data,"hahaha")
    const meetdata = res2.data.module_list.filter(item => item.show === true);
    console.log(meetdata[0])
    if(res2.data.background_current_type === 'color'){
      this.setData({
        color:res2.data.background_current,
      })
    }else if(res2.data.background_current_type === 'image'){
      this.setData({
        bagImg:res2.data.background_current_img,
        
      })
    }
    if(res2.data.logo_show){
      this.setData({
        logImg:res2.data.logo_src,

      })
    }
    
    this.setData({


      event_name:res2.data.event_name,
      event_desc:res2.data.event_desc,
      event_time:res2.data.event_time,
      event_address:res2.data.event_address,
      mettingdata:meetdata,
      'abstractdetail1data.id':res2.data.id,
      




    })
    const app = getApp();
    this.setData({ texts: app.globalData.lang });
    wx.getStorage({
      key: 'language',
      success:(res)=> {
       this.setData({
         language:res.data
       })
      }
    });
    console.log(this.data.texts)

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})